package com.grantheath.erebus.view 
{
	import com.grantheath.erebus.model.enum.notifications.ErebusAppStageNotifications;
	import org.puremvc.as3.interfaces.INotification;

	import com.grantheath.erebus.model.enum.names.ErebusMediatorNames;
	import flash.display.DisplayObjectContainer;
	import org.puremvc.as3.patterns.mediator.Mediator;
	import org.puremvc.as3.interfaces.IMediator;
	
	/**
	 * @author grantheath
	 */
	public class ErebusAppStageMediator extends Mediator implements IMediator 
	{
		public function ErebusAppStageMediator(viewComponent : DisplayObjectContainer)
		{
			super(ErebusMediatorNames.APP_STAGE_MEDIATOR, viewComponent);
		}

		override public function listNotificationInterests() : Array
		{
			return [ErebusAppStageNotifications.ADD_LAYER];
		}

		override public function handleNotification(notification : INotification) : void
		{
			var notificationName : String = notification.getName();
			
			if(notificationName == ErebusAppStageNotifications.ADD_LAYER) {
				var newLayer : DisplayObjectContainer = notification.getBody() as DisplayObjectContainer;
				
				viewComponent.addChild(newLayer);
			}
		}
	}
}
